package cn.wokoba.dao.mapper;

import cn.wokoba.dao.pojo.UserCreditAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

//用户积分账户
@Mapper
public interface UserCreditAccountMapper extends BaseMapper<UserCreditAccount> {

    @Update("""
                update user_credit_account set
                    total_amount = total_amount + #{totalAmount},
                    available_amount = available_amount + #{availableAmount}
                    where user_id = #{userId}\
            """)
    int updateAddAmount(UserCreditAccount userCreditAccountReq);

    @Select("   select user_id, total_amount, available_amount, account_status from user_credit_account\n" +
            "        where user_id = #{userId}")
    UserCreditAccount queryUserCreditAccount(UserCreditAccount userCreditAccountReq);
}
